package bb.lanxing.lib.devices.ble.ble.characteristic.light;

import com.baidu.platform.comapi.map.MapBundleKey;
//import com.garmin.fit.MonitoringReader;
import bb.lanxing.lib.devices.ble.ble.characteristic.light.LightBeamMode;
import bb.lanxing.lib.devices.ble.ble.characteristic.light.LightMode;
import bb.lanxing.lib.devices.ble.ble.characteristic.light.LightType;
import bb.lanxing.lib.kt.ByteArrayExtKt;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;

public final class LightMachineStatus {
    private final Integer beamFocusMode;
    private final LightBeamMode beamMode;
    private int byteIndex;
    private final Integer index;
    private final Integer intensity;
    private final LightMachineFlags lightMachineFlags;
    private final LightType lightType;
    private final LightMode modeType;

    public LightMachineStatus(byte[] byteArray) {
        Integer num;
        LightType lightType;
        LightMode lightMode;
        LightBeamMode lightBeamMode;
        Integer num2;
        Intrinsics.checkNotNullParameter(byteArray, "byteArray");
        Integer num3 = null;
        LightMachineFlags lightMachineFlags = new LightMachineFlags(ByteArrayExtKt.readUInt8(byteArray, 0, 1, null));
        this.lightMachineFlags = lightMachineFlags;
        if (lightMachineFlags.getIndexDataPresent()) {
            int i = this.byteIndex + 1;
            this.byteIndex = i;
            num = ByteArrayExtKt.readUInt8(byteArray, i);
        } else {
            num = null;
        }
        this.index = num;
        if (lightMachineFlags.getTypeDataPresent()) {
            LightType.Companion companion = LightType.Companion;
            int i2 = this.byteIndex + 1;
            this.byteIndex = i2;
            lightType = companion.from(ByteArrayExtKt.readUInt8(byteArray, i2));
        } else {
            lightType = null;
        }
        this.lightType = lightType;
        if (lightMachineFlags.getModeDataPresent()) {
            LightMode.Companion companion2 = LightMode.Companion;
            int i3 = this.byteIndex + 1;
            this.byteIndex = i3;
            lightMode = companion2.from(ByteArrayExtKt.readUInt8(byteArray, i3));
        } else {
            lightMode = null;
        }
        this.modeType = lightMode;
        if (lightMachineFlags.getBeamModeDataPresent()) {
            LightBeamMode.Companion companion3 = LightBeamMode.Companion;
            int i4 = this.byteIndex + 1;
            this.byteIndex = i4;
            lightBeamMode = companion3.from(ByteArrayExtKt.readUInt8(byteArray, i4));
        } else {
            lightBeamMode = null;
        }
        this.beamMode = lightBeamMode;
        if (lightMachineFlags.getBeamFocusDataPresent()) {
            int i5 = this.byteIndex + 1;
            this.byteIndex = i5;
            num2 = ByteArrayExtKt.readUInt8(byteArray, i5);
        } else {
            num2 = null;
        }
        this.beamFocusMode = num2;
        if (lightMachineFlags.getIntensityPresent()) {
            int i6 = this.byteIndex + 1;
            this.byteIndex = i6;
            num3 = ByteArrayExtKt.readUInt8(byteArray, i6);
        }
        this.intensity = num3;
    }

    public int getByteIndex() {
        return this.byteIndex;
    }

    public void setByteIndex(int i) {
        this.byteIndex = i;
    }

    public LightMachineFlags getLightMachineFlags() {
        return this.lightMachineFlags;
    }

    public Integer getIndex() {
        return this.index;
    }

    public LightType getLightType() {
        return this.lightType;
    }

    public LightMode getModeType() {
        return this.modeType;
    }

    public LightBeamMode getBeamMode() {
        return this.beamMode;
    }

    public Integer getBeamFocusMode() {
        return this.beamFocusMode;
    }

    public Integer getIntensity() {
        return this.intensity;
    }

    public boolean isLightOn() {
        return this.modeType != LightMode.Off;
    }
}
